## 17.2. mSQL Utilities

msql |

    msql [options] database

The mSQL command line monitor. This program is the most basic way to communicate with the mSQL server. SQL commands can be typed directly on the command line and the results are displayed on the screen. Statements can continue over multiple lines. No action is taken until a line ending with a command is entered.

#### Commands

\e

  Edit the previous statement using the default editor.

\g

  Submit statement to the database server.

\p

  Display the current statement.

\q

  Exit the program.

#### Options

-f file

  Use an alternate configuration file.

-h hostname

  Connect to the database server on a remote host.

msql2d |

    msql2d [options]

The mSQL server daemon. All other programs interact with the database through this server, so it should be left running at all times (except when down for maintenance).

#### Options

-f file

  Use an alternate configuration file.

msqladmin |

    msqladmin [options] command

Performs operations that affect the database server as a whole. This utility is used to shut down the database server, add and delete entire databases, and other administrative functions.

#### Commands

copy database newdatabase

  Create an exact duplicate of a database under a different name.

create database

  Create a new blank database.

drop database

  Remove a database and destroy its contents.

move database newdatabase

  Rename a database.

reload

  Reread the configuration files.

shutdown

  Terminate the database server.

stats

  Display statistics about the database server. This shows who is currently connected to the server, what database they are using and how many queries they have sent, among other things.

version

  Display the version information for the database server.

#### Options

-f file

  Use an alternate configuration file.

-h hostname

  Connect to a database server on a remote host.

-q

  Do not ask for verification of commands.

msqldump |

    msqldump [options] database[table]

Outputs the contents of the given database (or table within a database) as a series of ASCII SQL commands.

#### Options

-c

  Output complete INSERT statements.

-f file

  Use an alternate configuration file.

-h hostname

  Connect to a database server on a remote host.

-t

  Dump only the table creation statements; do not dump the data.

-w statement

  Use an SQL WHERE clause to limit the data outputted.

-v

  Display status information while dumping the data.

msqlexport |

    msqlexport [options]database table

Outputs the contents of the given table in ASCII delimited format.

#### Options

-e character

  Use `character` to escape any of the delimiter characters found in the data.

-h hostname

  Connect to a database server on a remote host.

-q character

  The character used to surround each data value.

-s character

  The character used to delimit the data.

-v

  Display status information while dumping the data.

msqlimport |

    msqlimport [options] database table

Reads an ASCII delimited file and inserts the data into the given table.

#### Options

-e character

  The character used to as an escape character in the data.

-h hostname

  Connect to a database server on a remote host.

-q character

  The character used to surround each data value.

-s character

  The character used to delimit the data.

-v

  Display status information while dumping the data.

relshow |

    relshow [options] [database] [table] [index|_seq]

Displays the layout of the requested database, table, index, or sequence. If no argument is given, a list of all of the databases is given. With one argument, the layout of the given database is shown. With two arguments, a table within the database is displayed. If all three arguments are present, the third argument must be an index within the given table, or `_seq`, in which case information about the sequence on the table is shown.

#### Options

-f file

  Use an alternate configuration file.

-h hostname

  Connect to a database server on a remote host.

Copyright © 2001 O'Reilly & Associates. All rights reserved.